package com.pk.platform.business.question.web;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import com.pk.platform.business.core.web.GenericAction;
import com.pk.platform.business.question.service.IPaperDefineService;
import com.pk.platform.business.question.service.IPaperUseService;
import com.pk.platform.business.question.vo.PaperVO;
import com.pk.platform.domain.question.Paper;
import com.pk.platform.domain.question.PaperFix;
import com.pk.platform.domain.question.Question;
import com.pk.platform.util.constant.Constant;

public class PaperUseAction extends GenericAction {

	private Paper paper = new Paper();
	
	private PaperVO pvo = new PaperVO();
	
	private PaperFix paperFix = new PaperFix();
	
	private Question qes = new Question();
	
	private IPaperDefineService paperDefineService;
	
	private IPaperUseService paperUseService;
	
	private Map<String, Object> returnObj = new HashMap<String, Object>();
	
	private String keyJson;
	
	public String paperUseManage()
	{
		return SUCCESS;
	}

	public String paperUseListByPage()
	{
		list = paperDefineService.queryPaperByPage(pvo, pager);
		return SUCCESS;
	}
	
	public String paperInstanceManage()
	{
		return SUCCESS;
	}

	public String paperInstanceListByPage()
	{
		list = paperUseService.queryPaperFixByPage(pvo, pager);
		return SUCCESS;
	}
	
	public String toAddPaperFix()
	{
		return SUCCESS;
	}
	
	public String addPaperFix()
	{
		paperFix.setPfTime(new Date());
		paperFix.setSaveFlag(Constant.N);
		returnObj = paperUseService.addPaperFix(paperFix);
		return SUCCESS;
	}
	
	public String toUpdatePaperFix()
	{
		paperFix = paperUseService.queryPaperFixById(paperFix.getId());
		keyJson = paperUseService.queryQuestionKeyListJson(paperFix.getId());
		return SUCCESS;
	}
	
	public String delPaperFix()
	{
		paperUseService.delPaperFix(paperFix.getId());
		return SUCCESS;
	}
	
	public String questionListByPaper()
	{
		list = paperUseService.queryQuestionListByPaper(paperFix.getPaper().getId());
		paper = paperDefineService.queryPaperById(paperFix.getPaper().getId());
		String jsonPaperStr = paperUseService.queryPaperJson(paperFix.getPaper().getId());
		returnObj.put("jsonPaperStr", jsonPaperStr);
		returnObj.put("qesList", list);
		return SUCCESS;
	}
	
	public String toSearchError()
	{
		return SUCCESS;
	}
	
	
	
	public Paper getPaper() {
		return paper;
	}

	public void setPaper(Paper paper) {
		this.paper = paper;
	}

	public PaperVO getPvo() {
		return pvo;
	}

	public void setPvo(PaperVO pvo) {
		this.pvo = pvo;
	}

	public PaperFix getPaperFix() {
		return paperFix;
	}

	public void setPaperFix(PaperFix paperFix) {
		this.paperFix = paperFix;
	}

	public Question getQes() {
		return qes;
	}

	public void setQes(Question qes) {
		this.qes = qes;
	}

	public void setPaperDefineService(IPaperDefineService paperDefineService) {
		this.paperDefineService = paperDefineService;
	}

	public void setPaperUseService(IPaperUseService paperUseService) {
		this.paperUseService = paperUseService;
	}

	public Map<String, Object> getReturnObj() {
		return returnObj;
	}

	public void setReturnObj(Map<String, Object> returnObj) {
		this.returnObj = returnObj;
	}

	public String getKeyJson() {
		return keyJson;
	}

	public void setKeyJson(String keyJson) {
		this.keyJson = keyJson;
	}

}
